home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / geebee.c < prev    next >
C/C++ Source or Header  |  2000-05-20  |  5KB  |  244 lines

  1. /****************************************************************************
  2.  *
  3.  * geebee.c
  4.  *
  5.  * video driver
  6.  * juergen buchmueller <pullmoll@t-online.de>, jan 2000
  7.  *
  8.  * TODO:
  9.  * backdrop support for lamps? (player1, player2 and serve)
  10.  * what is the counter output anyway?
  11.  * add overlay colors for Navalone and Kaitei Takara Sagashi
  12.  *
  13.  ****************************************************************************/
  14.  
  15. #include "driver.h"
  16. #include "artwork.h"
  17. #include "vidhrdw/generic.h"
  18.  
  19. /* from machine/geebee.c */
  20. extern int geebee_ball_h;
  21. extern int geebee_ball_v;
  22. extern int geebee_lamp1;
  23. extern int geebee_lamp2;
  24. extern int geebee_lamp3;
  25. extern int geebee_counter;
  26. extern int geebee_lock_out_coil;
  27. extern int geebee_bgw;
  28. extern int geebee_ball_on;
  29. extern int geebee_inv;
  30.  
  31. #ifdef MAME_DEBUG
  32. char geebee_msg[32+1];
  33. int geebee_cnt;
  34. #endif
  35.  
  36.  
  37. static unsigned char palette[] =
  38. {
  39.     0x00,0x00,0x00, /* black */
  40.     0xff,0xff,0xff, /* white */
  41.     0x7f,0x7f,0x7f  /* grey  */
  42. };
  43.  
  44. static unsigned short geebee_colortable[] =
  45. {
  46.      0, 1,
  47.      0, 2,
  48.      1, 0,
  49.      2, 0
  50. };
  51.  
  52. static unsigned short navalone_colortable[] =
  53. {
  54.      0, 1,
  55.      0, 2,
  56.      0, 1,
  57.      0, 2
  58. };
  59.  
  60.  
  61. #define PINK1    0xa0,0x00,0xe0,OVERLAY_DEFAULT_OPACITY
  62. #define PINK2     0xe0,0x00,0xf0,OVERLAY_DEFAULT_OPACITY
  63. #define ORANGE    0xff,0xd0,0x00,OVERLAY_DEFAULT_OPACITY
  64. #define BLUE    0x00,0x00,0xff,OVERLAY_DEFAULT_OPACITY
  65.  
  66. #define    END  {{ -1, -1, -1, -1}, 0,0,0,0}
  67.  
  68. static const struct artwork_element geebee_overlay[]=
  69. {
  70.     {{  1*8,  4*8-1,    0,32*8-1 }, PINK2  },
  71.     {{  4*8,  5*8-1,    0, 6*8-1 }, PINK1  },
  72.     {{  4*8,  5*8-1, 26*8,32*8-1 }, PINK1  },
  73.     {{  4*8,  5*8-1,  6*8,26*8-1 }, ORANGE },
  74.     {{  5*8, 28*8-1,    0, 3*8-1 }, PINK1  },
  75.     {{  5*8, 28*8-1, 29*8,32*8-1 }, PINK1  },
  76.     {{  5*8, 28*8-1,  3*8, 6*8-1 }, BLUE   },
  77.     {{  5*8, 28*8-1, 26*8,29*8-1 }, BLUE   },
  78.     {{ 12*8, 13*8-1, 15*8,17*8-1 }, BLUE   },
  79.     {{ 21*8, 23*8-1, 12*8,14*8-1 }, BLUE   },
  80.     {{ 21*8, 23*8-1, 18*8,20*8-1 }, BLUE   },
  81.     {{ 28*8, 29*8-1,    0,32*8-1 }, PINK2  },
  82.     {{ 29*8, 32*8-1,    0,32*8-1 }, PINK1  },
  83.     END
  84. };
  85.  
  86. int geebee_vh_start(void)
  87. {
  88.     if( generic_vh_start() )
  89.         return 1;
  90.  
  91.     /* use an overlay only in upright mode */
  92.  
  93.     if( (readinputport(2) & 0x01) == 0 )
  94.     {
  95.         overlay_create(geebee_overlay, 3, Machine->drv->total_colors-3);
  96.     }
  97.  
  98.     return 0;
  99. }
  100.  
  101. int navalone_vh_start(void)
  102. {
  103.     if( generic_vh_start() )
  104.         return 1;
  105.  
  106.     /* overlay? */
  107.  
  108.     return 0;
  109. }
  110.  
  111. int sos_vh_start(void)
  112. {
  113.     if( generic_vh_start() )
  114.         return 1;
  115.  
  116.     /* overlay? */
  117.  
  118.     return 0;
  119. }
  120.  
  121. int kaitei_vh_start(void)
  122. {
  123.     if( generic_vh_start() )
  124.     return 1;
  125.  
  126.     /* overlay? */
  127.  
  128.     return 0;
  129. }
  130.  
  131. /* Initialise the palette */
  132. void geebee_init_palette(unsigned char *sys_palette, unsigned short *sys_colortable, const unsigned char *color_prom)
  133. {
  134.     memcpy(sys_palette, palette, sizeof (palette));
  135.     memcpy(sys_colortable, geebee_colortable, sizeof (geebee_colortable));
  136. }
  137.  
  138. /* Initialise the palette */
  139. void navalone_init_palette(unsigned char *sys_palette, unsigned short *sys_colortable, const unsigned char *color_prom)
  140. {
  141.     memcpy(sys_palette, palette, sizeof (palette));
  142.     memcpy(sys_colortable, navalone_colortable, sizeof (navalone_colortable));
  143. }
  144.  
  145.  
  146. INLINE void geebee_plot(struct osd_bitmap *bitmap, int x, int y)
  147. {
  148.     struct rectangle r = Machine->drv->visible_area;
  149.     if (x >= r.min_x && x <= r.max_x && y >= r.min_y && y <= r.max_y)
  150.         plot_pixel(bitmap,x,y,Machine->pens[1]);
  151. }
  152.  
  153. INLINE void mark_dirty(int x, int y)
  154. {
  155.     int cx, cy, offs;
  156.     cy = y / 8;
  157.     cx = x / 8;
  158.     if (geebee_inv)
  159.     {
  160.         offs = (32 - cx) + (31 - cy) * 32;
  161.         dirtybuffer[offs % videoram_size] = 1;
  162.         dirtybuffer[(offs - 1) & (videoram_size - 1)] = 1;
  163.         dirtybuffer[(offs - 32) & (videoram_size - 1)] = 1;
  164.         dirtybuffer[(offs - 32 - 1) & (videoram_size - 1)] = 1;
  165.     }
  166.     else
  167.     {
  168.         offs = (cx - 1) + cy * 32;
  169.         dirtybuffer[offs & (videoram_size - 1)] = 1;
  170.         dirtybuffer[(offs + 1) & (videoram_size - 1)] = 1;
  171.         dirtybuffer[(offs + 32) & (videoram_size - 1)] = 1;
  172.         dirtybuffer[(offs + 32 + 1) & (videoram_size - 1)] = 1;
  173.     }
  174. }
  175.  
  176. void geebee_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
  177. {
  178.     int offs;
  179.  
  180. #ifdef MAME_DEBUG
  181.     if( geebee_cnt > 0 )
  182.     {
  183.         ui_text(Machine->scrbitmap, geebee_msg, Machine->drv->visible_area.min_y, Machine->drv->visible_area.max_x - 8);
  184.         if( --geebee_cnt == 0 )
  185.             full_refresh = 1;
  186.     }
  187. #endif
  188.  
  189.     if (palette_recalc() || full_refresh )
  190.         memset(dirtybuffer, 1, videoram_size);
  191.  
  192.     for( offs = 0; offs < videoram_size; offs++ )
  193.     {
  194.         if( dirtybuffer[offs] )
  195.         {
  196.             int mx,my,sx,sy,code,color;
  197.  
  198.             dirtybuffer[offs] = 0;
  199.  
  200.             mx = offs % 32;
  201.             my = offs / 32;
  202.  
  203.             if (my == 0)
  204.             {
  205.                 sx = 8*33;
  206.                 sy = 8*mx;
  207.             }
  208.             else if (my == 1)
  209.             {
  210.                 sx = 0;
  211.                 sy = 8*mx;
  212.             }
  213.             else
  214.             {
  215.                 sx = 8*(mx+1);
  216.                 sy = 8*my;
  217.             }
  218.  
  219.             if (geebee_inv)
  220.             {
  221.                 sx = 33*8 - sx;
  222.                 sy = 31*8 - sy;
  223.             }
  224.  
  225.             code = videoram[offs];
  226.             color = ((geebee_bgw & 1) << 1) | ((code & 0x80) >> 7);
  227.             drawgfx(bitmap,Machine->gfx[0],
  228.                     code,color,
  229.                     geebee_inv,geebee_inv,sx,sy,
  230.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  231.         }
  232.     }
  233.  
  234.     if( geebee_ball_on )
  235.     {
  236.         int x, y;
  237.  
  238.         mark_dirty(geebee_ball_h+5,geebee_ball_v-2);
  239.         for( y = 0; y < 4; y++ )
  240.             for( x = 0; x < 4; x++ )
  241.                 geebee_plot(bitmap,geebee_ball_h+x+5,geebee_ball_v+y-2);
  242.     }
  243. }
  244.